package com.lagou.stage02;

public class PhoneCard{
    private String card_type;
    private int number;
    private String user_name;
    private String password;
    private double balance;
    private double duration;
    private double internet_traffic;

    public PhoneCard(String card_type, int number, String user_name, String password, double balance) {
        this.card_type = card_type;
        this.number = number;
        this.user_name = user_name;
        this.password = password;
        this.balance = balance;
    }

    public void setDuration(double duration) {
        this.duration = duration;
    }

    public void setInternetTraffic(double internet_traffic) {
        this.internet_traffic = internet_traffic;
    }

    public double getDuration() {
        return duration;
    }

    public double getInternetTraffic() {
        return internet_traffic;
    }

    // 定义获取当前余额的方法
    public double getBalance(UserConsumeData ucd) {
        balance -= ucd.getSumMonthlyConsume();
        return balance;
    }

    // 定义模拟使用通话的方法
    public void calling(CallService cs, double duration) {
        cs.callServiceAction(duration, card_type);
        setDuration(duration);
    }

    // 定义模拟使用上网冲浪的方法
    public void surfing(NetworkService ns, double internet_traffic) {
        ns.networkServiceAction(internet_traffic, card_type);
        setInternetTraffic(internet_traffic);
    }

    public void show() {
        System.out.println("当前卡号：" + number + "，用户名：" + user_name + "，当前余额：" + balance);
    }

    public void showDetails() {
        System.out.println("卡类型：" + card_type + "，卡号：" + number + "，用户名：" + user_name + "，用户密码：" +
                password + "，余额：" + balance + "元，本月累计通话时长" + getDuration() +  "分钟, 本月累计上网流量：" + getInternetTraffic() + "GB");
    }
}
